package test00.lx05.t03;

import test00.lx04.t01.Student;

import java.util.function.Consumer;

/**
 * @author ZQX
 * @date 2025-04-07
 */
public class MainTest {
    public static void main(String[] args) {
        Student[] arrStudents = {
                new Student("张三", 18),
                new Student("李四", 8),
                new Student("王老五", 38),
                new Student("赵六", 28),
                new Student("田七七", 7),
        };


        // void accept(T t);
        Consumer<Student[]> consumer01 = (stuArr) -> {
            System.out.println("=====姓李的学生有=====");
            for (Student stu : stuArr) {
                if (stu.getName().startsWith("李")) {
                    System.out.println(stu);
                }
            }
            System.out.println();
        };

        // consumer01.accept(arrStudents);



        Consumer<Student[]> consumer02 = (stuArr) -> {
            System.out.println("=====姓名有三个字的学生有=====");
            for (Student stu : stuArr) {
                if (stu.getName().length() == 3) {
                    System.out.println(stu);
                }
            }
            System.out.println();
        };

        // consumer02.accept(arrStudents);


        Consumer<Student[]> consumer03 = (stuArr) -> {
            System.out.println("=====年龄大于18岁的学生有=====");
            for (Student stu : stuArr) {
                if (stu.getAge() > 18) {
                    System.out.println(stu);
                }
            }
            System.out.println();
        };
        // consumer03.accept(arrStudents);
        consumer01.andThen(consumer02).andThen(consumer03).accept(arrStudents);

    }
}
